package com.devbobcorn.nekoration.sounds;

import java.util.HashMap;
import java.util.Map;

import com.devbobcorn.nekoration.Nekoration;

import net.minecraft.client.audio.BackgroundMusicSelector;
import net.minecraft.client.audio.BackgroundMusicTracks;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class ModSounds {
    public static final DeferredRegister<SoundEvent> SOUNDEVENTS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, Nekoration.MODID);

    public static final Map<String, RegistryObject<SoundEvent>> CUSTOM_MUSIC = new HashMap<>();

    public static final Map<String, BackgroundMusicSelector> CUSTOM_TRACKS = new HashMap<>();

    public static final int MAX_FRAME = 300000; // Maximum 5 minutes

    public static final String[] MUSIC_NAMES = { };

    public static void initTracks(){
        for (String musicName : MUSIC_NAMES){
            CUSTOM_MUSIC.put(musicName, SOUNDEVENTS.register(musicName, () -> {
                SoundEvent event = new SoundEvent(new ResourceLocation(Nekoration.MODID, musicName));
                CUSTOM_TRACKS.put(musicName, BackgroundMusicTracks.createGameMusic(event));
                return event;
            }));
        }
    }
}